package day6Exer;

public class Animal {
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.setName("加菲猫");
        cat.setAge(10);
        System.out.println("猫的名字为"+cat.getName()+"，猫的年龄为"+cat.getAge());
        cat.voice();
        cat.eat();
        Dog dog = new Dog();
        dog.setAge(10);
        dog.setName("欧弟");
        System.out.println("狗的名字为"+dog.getName()+"，狗的年龄为"+dog.getAge());
        dog.voice();
        dog.eat();


    }
    private String name;
    private int age;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
class Cat extends Animal{
    public void voice(){
        System.out.println("叫声为喵喵喵");
    }
    public void eat(){
        System.out.println("吃鱼");
    }
}
class Dog extends Animal{
    public void voice(){
        System.out.println("叫声汪汪汪");
    }
    public void eat(){
        System.out.println("吃骨头");
    }
}